//
//  XLSwitchCompanyCell.m
//  industry
//
//  Created by xl on 2020/11/26.
//  Copyright © 2020 Haier. All rights reserved.
//

#import "XLSwitchCompanyCell.h"
#import "XLCompanyModel.h"

@interface XLSwitchCompanyCell ()

@property (nonatomic, strong) XLView *bgView;
@property (nonatomic, strong) XLImageView *iconIG;
@property (nonatomic, strong) XLLabel *titleLB;
@property (nonatomic, strong) XLButton *tagBtn;
@property (nonatomic, strong) XLButton *advanceCerBtn;
@property (nonatomic, strong) XLLabel *infoLB;
@property (nonatomic, strong) XLImageView *arrowIG;

@end

@implementation XLSwitchCompanyCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteBgColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        [self.contentView addSubview:self.bgView];
        [_bgView addSubview:self.iconIG];
        [_bgView addSubview:self.titleLB];
        [_bgView addSubview:self.tagBtn];
        [_bgView addSubview:self.advanceCerBtn];
        [_bgView addSubview:self.infoLB];
        [_bgView addSubview:self.arrowIG];
        
        [self makeConstraints];
    }
    return self;
}

- (void)makeConstraints {
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.top.bottom.equalTo(self.contentView);
    }];
    
    [_iconIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView).offset(20);
        make.centerY.equalTo(self.bgView);
        make.size.mas_equalTo(CGSizeMake(34, 34));
    }];
    
    [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIG.mas_right).offset(10);
        make.top.equalTo(self.bgView).offset(15);
    }];
    
    [_tagBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLB.mas_right).offset(5);
        make.centerY.equalTo(self.titleLB);
        make.size.mas_equalTo(CGSizeMake(40, 15));
    }];
    
    [_advanceCerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIG.mas_right).offset(10);
        make.top.equalTo(self.titleLB.mas_bottom).offset(4);
        make.size.mas_equalTo(CGSizeMake(72, 20));
    }];
    
    [_arrowIG mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView).offset(-20);
        make.centerY.equalTo(self.bgView);
        make.size.mas_equalTo(CGSizeMake(10, 18));
    }];
    
    [_infoLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLB);
        make.top.equalTo(self.advanceCerBtn.mas_bottom).offset(4);
    }];
}

#pragma mark - Public
- (void)loadCellData:(XLCompanyModel *)model {
    _titleLB.text = model.firmName;
    _infoLB.text = [NSString stringWithFormat:@"我在该团队内的名字：%@", XL_UserInfoData.employeeName];
}

#pragma mark - Setter/getter
- (XLView *)bgView {
    if (!_bgView) {
        _bgView = [XLView new];
        _bgView.backgroundColor = [UIColor whiteColor];
        _bgView.layer.cornerRadius = 20.0f;
        _bgView.layer.shadowColor = [UIColor colorWithHex:0x000000 alpha:0.08].CGColor;
        _bgView.layer.shadowOffset = CGSizeMake(0,-6);
        _bgView.layer.shadowOpacity = 1;
        _bgView.layer.shadowRadius = 20;
    }
    return _bgView;
}

- (XLImageView *)iconIG {
    if (!_iconIG) {
        _iconIG = [XLImageView new];
        _iconIG.backgroundColor = [UIColor blueBgColor];
    }
    return _iconIG;
}

- (XLLabel *)titleLB {
    if (!_titleLB) {
        _titleLB = [XLLabel new];
        _titleLB.font = [UIFont fontOfPingFangSCSemiboldWithSize:13];
        _titleLB.textColor = [UIColor blackFontColor];
    }
    return _titleLB;
}

- (XLButton *)tagBtn {
    if (!_tagBtn) {
        _tagBtn = [XLButton new];
        _tagBtn.backgroundColor = [UIColor whiteBgColor];
        _tagBtn.layer.cornerRadius = 7.5;
        _tagBtn.layer.masksToBounds = YES;
        _tagBtn.layer.borderWidth = 1.0f;
        _tagBtn.layer.borderColor = [UIColor colorWithHex:0x1B69FD].CGColor;
        _tagBtn.titleLabel.font = [UIFont fontOfPingFangSCRegularWithSize:10];
        [_tagBtn setTitleColor:[UIColor colorWithHex:0x1B69FD] forState:UIControlStateNormal];
        [_tagBtn setTitle:@"主企业" forState:UIControlStateNormal];
        _tagBtn.userInteractionEnabled = NO;
    }
    return _tagBtn;
}

- (XLButton *)advanceCerBtn {
    if (!_advanceCerBtn) {
        _advanceCerBtn = [XLButton new];
        [_advanceCerBtn setImage:XLIMAGE(@"rz") forState:UIControlStateNormal];
        [_advanceCerBtn setTitle:@"高级认证" forState:UIControlStateNormal];
        _advanceCerBtn.userInteractionEnabled = NO;
    }
    return _advanceCerBtn;
}

- (XLImageView *)arrowIG {
    if (!_arrowIG) {
        _arrowIG = [XLImageView new];
        _arrowIG.image = XLIMAGE(@"hsjt");
    }
    return _arrowIG;
}

- (XLLabel *)infoLB {
    if (!_infoLB) {
        _infoLB = [XLLabel new];
        _infoLB.font = [UIFont fontOfPingFangSCRegularWithSize:11];
        _infoLB.textColor = [UIColor graySecondFontColor];
    }
    return _infoLB;
}

@end
